<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
    <meta content="telephone=no" name="format-detection" />
    <!-- 留作将来统一添加 -->
    <TEMPLATE>${TEMPLATE}</TEMPLATE>
    <title>模板html</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/index.css">
    <link rel="stylesheet" type="text/css" href="../../css/data-flex.min.css">
    <style type="text/css">
        .books {
            padding: 0 7.5px;
            flex-wrap: wrap;
        }

        .book {
            width: 33.333%;
            padding: 0 7.5px;
        }

        .image {
            position: relative;
            width: 105px;
            height: 140px;
            margin: 15px auto 0 auto;
            background: rgba(77, 181, 216, 1);
            box-shadow: 0px 2px 9px 0px rgba(0, 0, 0, 0.16);
            border-radius: 5px;
            overflow: hidden;
        }

        .title {
            width: 105px;
            height: 32px;
            margin: 8px auto 0 auto;
            font-size: 14px;
            font-weight: 400;
            color: rgba(25, 25, 25, 1);
            line-height: 16px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 2;
        }
    </style>
</head>
<body>
    <div class="vueApp" v-cloak>
        <div class="books" data-flex>
            <div class="book" v-for="item in listData" @click="handleItem(item)">
                <div class="image">
                    <img :src="item.pbookPic" alt="">
                </div>
                <div class="title">
                    {{ item.pbookName }}
                </div>
            </div>
        </div>
        <div v-show="loadEnd && !listData.length" class="data-null">
            <p>暂时没有更多数据哦</p>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/service/service-tool.js"></script>
<script type="text/javascript" src="../../script/service/service-app.js"></script>
<script type="text/javascript" src="../../script/service/service-user.js"></script>
<script type="text/javascript" src="../../script/service/service-logic.js"></script>
<script type="text/javascript" src="../../script/jquery.min.js"></script>
<script type="text/javascript" src="../../script/vue.min.js"></script>
<script type="text/javascript">
    // html 的引号一律为双引号(""),js 为单引号('')
    var USER, $S, vm;
    apiready = function() {
        $S = SERVICE();
        USER = USER();
        console.log(JSON.stringify(api.pageParam) + '=====pageParam');

        fnInit();
    };
    // 初始化
    function fnInit() {
        vm = new Vue({
            el: '.vueApp',
            data: {
                listData: [],
                loadEnd: false
            }
        });
        load();
    }

    function load() {
        getPageData('headerRefreshing');
        fnAddHeaderRefreshingEvent(function() { //设置下拉刷新
            getPageData('headerRefreshing');
        });

        fnAddFooterLoadingEvent(function() { // 设置上拉加载
            getPageData('load');
        });
    }

    // 获取页面数据
    function getPageData(sign) {
        if(sign == 'headerRefreshing') {
            vm.pageNo = 1;
        } else {
            vm.pageNo ++;
        }
        var url = 'stuPicture/findMyBuyStuPictureBookList';
        var params = {};
        var callback = function(data) {
            if(vm.pageNo == '1') {
                vm.listData = [];
            }
            vm.listData = vm.listData.concat(data.listData);
            vm.loadEnd = true;
            // status 为200时,只返回data
        };
        var error = function(res) {
            // status 不是200时,全部返回
            api.refreshHeaderLoadDone();
        };
        POST(url, params, callback, error);
    }

    // 点击绘本
    function handleItem(item) {
        fnOpenPublicWin(item.pbookName, 'video/hb_detail', {
            hbId: item.id
        });
    }
</script>
</html>